using System;
using System.Transactions;

namespace MSTestExtensions
{
    /// <remarks />
    [AttributeUsage(AttributeTargets.Method)]
    public sealed class TestTransactionAttribute : Attribute
    {
        #region Fields

        /// <remarks />
        private readonly bool _commit;

        /// <remarks />
        private readonly TransactionScopeOption _transactionScopeOption;

        /// <remarks />
        private readonly TransactionOptions _transactionOptions;

        #endregion // Fields

        #region Constructors

        /// <remarks />
        public TestTransactionAttribute()
            : this(false, TransactionScopeOption.Required, new TransactionOptions())
        {
        }

        /// <remarks />
        public TestTransactionAttribute(bool commit)
            : this(commit, TransactionScopeOption.Required, new TransactionOptions())
        {
        }

        /// <remarks />
        public TestTransactionAttribute(bool commit, TransactionScopeOption transactionScopeOption, TransactionOptions transactionOptions)
        {
            _commit = commit;
            _transactionScopeOption = transactionScopeOption;
            _transactionOptions = transactionOptions;
        }

        #endregion // Constructors

        #region Properties

        /// <remarks />
        public bool Commit
        {
            get { return _commit; }
        }

        /// <remarks />
        public TransactionScopeOption TransactionScopeOption
        {
            get { return _transactionScopeOption; }
        }

        /// <remarks />
        public TransactionOptions TransactionOptions
        {
            get { return _transactionOptions; }
        }

        #endregion // Properties
    }
}
